<template>
  <section>
      <div class="bii-box-section">
            
    
            <el-form :inline="true" :model="listQuery" style="margin-top:20px;">
                <el-form-item label="">
                    <el-select class="w100" size="mini" v-model="listQuery.type">
                        <el-option label="创建日期" value="1"></el-option>
                        <el-option label="结算日期" value="2"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="" v-if="listQuery.type=='1'">
                    <el-date-picker
                        value-format="yyyy-MM-dd"
                        size="mini"
                        v-model="date"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="" v-if="listQuery.type=='2'">
                    <el-date-picker
                        value-format="yyyy-MM-dd"
                        size="mini"
                        v-model="date2"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="">
                    <el-select placeholder="结算状态" class="w100" size="mini" v-model="listQuery.settleStatus" clearable>
                        <el-option label="待结算" value="1"></el-option>
                        <el-option label="已结算" value="5"></el-option>
                        <el-option label="已失效" value="10"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="">
                    <common-input style="width:150px;" placeholder="订单号" v-model="listQuery.orderNo" />
                </el-form-item>
                <el-form-item label="">
                    <common-input style="width:150px;" placeholder="供应商" v-model="listQuery.agencyName" />
                </el-form-item>
                <el-form-item>
                    <el-button size="mini" type="primary" @click="handleFilter">查询</el-button>
                    <el-button size="mini" @click="exportExcel">导出明细</el-button>
                </el-form-item>
            </el-form>

            <el-table ref="dataTable" :data="list" style="width: 100%">
                <el-table-column align="left" label="供应商">
                    <template slot-scope="scope">
                        <span>{{scope.row.agencyName}}</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="创建时间" width="150">
                    <template slot-scope="scope">
                        <span>{{scope.row.createdAt}}</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="结算时间" width="150">
                    <template slot-scope="scope">
                        <span>{{scope.row.settleTime}}</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="结算状态">
                    <template slot-scope="scope">
                        <span>{{scope.row.settleStatusText}}</span>
                    </template>
                </el-table-column>
                <el-table-column align="right" label="结算金额" width="100">
                    <template slot-scope="scope">
                        <span>￥{{scope.row.settleAmount}}</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="订单号" width="180">
                    <template slot-scope="scope">
                        <el-link type="primary" @click="handleDetail(scope.row)">{{scope.row.orderNo}}</el-link>
                    </template>
                </el-table-column>
                <el-table-column align="left" label="商品">
                    <template slot-scope="scope">
                        <span>{{scope.row.title}}</span>
                    </template>
                </el-table-column>
                <el-table-column align="right" label="规格">
                    <template slot-scope="scope">
                        <span>{{scope.row.attribute}}</span>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.pageNum" :page-sizes="[20,30, 50]" :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"> </el-pagination>
            </div>
        </div>
  </section>
</template>

<script>
    import {
        order_settle_list
    } from '../../api/order';
    export default {
        components: {
        },
        data() {
            return {
                listQuery: {
                    settleStartDate: undefined,
                    settleEndDate: undefined,
                    startDate: undefined,
                    endDate: undefined,
                    settleStatus: undefined,
                    pageNum: 1,
                    pageSize: 20,
                    orderNo: undefined,
                    agencyName: undefined,
                    type: "1"
                },
                list: [],
                total: 0,
                date: undefined
            }
        },
        mounted() {
        
        },
        created() {
            this.handleFilter();
        },
        methods: {
            handleFilter() {
                this.listQuery.pageNum = 1;
                this.getList();
            },
            handleSizeChange(val) {
                this.listQuery.pageSize = val;
                this.getList();
            },
            handleCurrentChange(val) {
                this.listQuery.pageNum = val;
                this.getList();
            },
            getList() {
                if(this.listQuery.type == "1") {
                    if(this.date) {
                        this.listQuery.startDate = this.date[0];
                        this.listQuery.endDate = this.date[1];
                    } else {
                        this.listQuery.startDate = undefined;
                        this.listQuery.endDate = undefined;
                    }
                    this.listQuery.settleStartDate = undefined;
                    this.listQuery.settleEndDate = undefined;
                } else if(this.listQuery.type == "2") {
                    if(this.date2) {
                        this.listQuery.settleStartDate = this.date2[0];
                        this.listQuery.settleEndDate = this.date2[1];
                    } else {
                        this.listQuery.settleStartDate = undefined;
                        this.listQuery.settleEndDate = undefined;
                    }
                    this.listQuery.startDate = undefined;
                    this.listQuery.endDate = undefined;
                }
                order_settle_list(this.listQuery).then(response => {
                    this.list = response.data.list;
                    this.total = response.data.total;
                })
            },
            handleDetail(row) {
                let {href} = this.$router.resolve({path: '/order_detail?id=' + row.orderId});
                window.open(href, '_blank');

            },
            exportExcel() {

            }
        }
    };
</script>
<style lang="scss" scoped>
    .bii-box-section {
        // padding: 80px;
        height: 100%;
        background: #fff;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        overflow: auto;

        .bd-head {
            position: relative;

            .head-price {
                font-size: 14px;
                display: -webkit-box;
                display: -ms-flexbox;
                display: flex;
                -webkit-box-align: center;
                -ms-flex-align: center;
                align-items: center;
                line-height: 16px;
                text-align: center;
                margin-bottom: 30px;

                .num {
                    font-size: 34px;
                    line-height: 36px;
                }

                .line {
                    height: 66px;
                    width: 1px;
                    background: #d8d8d8;
                    margin: 0 75px;
                }
            }
        }

        
    }
</style>
